package com.bos.web.action;

/**
 * @author misterWei
 * @create 2019年01月13号:17点45分
 * @mailbox mynameisweiyan@gmail.com
 */

import com.bos.domian.system.Permission;
import com.bos.service.PermsService;
import com.bos.web.BaseAction;
import com.opensymphony.xwork2.ActionContext;
import org.apache.struts2.convention.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import java.util.List;

@ParentPackage("json-default")
@Actions
@Controller
@Namespace("/")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PermissionAction extends BaseAction<Permission> {

    @Autowired
    private PermsService permsService;

    @Action(value = "permission_list", results = {@Result(name = "success", type = "json")})
    public String permissionList() {
        List<Permission> permissionList = permsService.findAll();
        ActionContext.getContext().getValueStack().push(permissionList);
        return SUCCESS;
    }
    /**权限的添加以及修改调通此方法即可
     *
     * */
    @Action(value = "permission_save",results = {@Result(name = "success",type = "redirect",location = "pages/system/permission.html")})
    public String permissionSave(){
        this.permsService.save(model);
        return SUCCESS;
    }
}
